package com.example.day04;


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * spring - xml解析
 */
public class SpirngBean {

    public static void main(String[] args) {

        /**
         * spring xml 解析技术  -sax,dom4j,jaxb
         * dom4j  经典
         * 读取applicationContext,xml
         * 有办法取出有效信息com.example.day04
         */

        String className="com.example.day04.Customer";

        //反射创建这个类的对象
        try {
            Class<?> c=Class.forName(className);

            Customer customer= (Customer) c.newInstance();

            // xml 解析 -id
            String  id="id";
            String  sid="set"+"Id";

            Method m=c.getDeclaredMethod(sid,int.class);
            m.invoke(customer,100);

            System.out.println(customer.getId());


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
